import redis
import numpy as np
import cv2


if __name__ == '__main__':
    key = ''

    r = redis.Redis(db=0)
    # r_remote = redis.Redis(host='192.168.31.159', db=0)
    # out = cv2.VideoWriter('project.avi', cv2.VideoWriter_fourcc(*'XVID'), 4, (1920, 1080))
    cv2.namedWindow("zed", cv2.WINDOW_GUI_NORMAL)
    cv2.setWindowProperty('zed', cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN)

    while key != 27:
        # img = np.frombuffer(r.get('mask_image'), dtype='uint8').reshape(1080, 1920, 3)
        img = np.frombuffer(r.get('image'), dtype='uint8').reshape(1080, 1920, 4)
        # depth = np.frombuffer(r.get('depth'), dtype='float32').reshape(720, 1280, 4)
        # img = np.frombuffer(r_remote.get('img'), dtype='uint8').reshape(480, 640, 3)

        cv2.imshow('zed', img)
        # out.write(img)
        key = cv2.waitKey(15)

    # out.release()
